import { BASIC_FLAG } from "$utils/enum";
import { getImg } from "$utils/imgs";
import { transitionParams } from "$utils/index";

export default {
  data() {
    return {
      basicFlag: BASIC_FLAG
    };
  },
  methods: {
    // 跳转新增页面
    pageSkip(item, flag) {
      const params = {
        id: item.id,
        useFlag: flag,
        dicName: null,
        dicValue: null,
        selctColor: null,
        selectBg: null
      }
      uni.navigateTo({
        url: transitionParams(params, "/pages/taskType/add/index", item),
      });
    },
    rightOptiopClick(item, op) {
      const { text } = op
      const { REMOVE, EDIT, ENABLE, DISABLE } = this.basicFlag
      switch (text) {
        case "删除":
          this.openDialog(item, REMOVE)
          break;
        case "启用":
          this.openDialog(item, ENABLE)
          break;
        case "禁用":
          this.openDialog(item, DISABLE)
          break;
        case "编辑":
          this.pageSkip(item, EDIT)
          break;
      }
    },
    setImgUrl(item) {
      const url = getImg(item.selectBg)
      return url
    }

  }
};
